"use strict";

import Vue from 'vue';
import axios from "axios";


let config = {
  // baseURL: "http://172.21.0.110:9633",
    baseURL: "http://192.168.25.175:9633",
  // timeout: 60 * 1000, // Timeout
  withCredentials: true, // Check cross-site Access-Control
};

const http = axios.create(config);

http.interceptors.request.use(
  function(config) {
    // Do something before request is sent
    //  config.headers['Access-Control-Allow-Origin'] = '*'; // 设置允许跨域的域名，*表示所有域名都可以跨域
      return config;
  },
  function(error) {
    // Do something with request error
    return Promise.reject(error);
  }
);

// Add a response interceptor
http.interceptors.response.use(
  function(response) {
    // Do something with response data
    return response;
  },
  function(error) {
    // Do something with response error
    return Promise.reject(error);
  }
);

// Plugin.install = function(Vue, options) {
//   Vue.axios = _axios;
//   window.axios = _axios;
//   Object.defineProperties(Vue.prototype, {
//     axios: {
//       get() {
//         return _axios;
//       }
//     },
//     $axios: {
//       get() {
//         return _axios;
//       }
//     },
//   });
// };
//
// Vue.use(http)

export default http;


